<template>
  <view class="dt-flex" style="justify-content: center">
    <view @click="onAgress" style="margin-top: 2rpx">
      <image
        :src="
          modelValue
            ? 'https://static.tospurfang.com/bd/choice.png'
            : 'https://static.tospurfang.com/bd/un_choice.png'
        "
        mode="widthFix"
        style="width: 28rpx; height: 28rpx"></image>
    </view>
    <view style="margin-left: 12rpx; font-size: 24rpx; line-height: 36rpx">
      <text style="color: #adadad">我已阅读并同意</text>
      <template v-for="(item, idx) in agrees" :key="idx">
        <text style="color: #5c71a1" @click="onRead(item)">《{{ item.title }}》</text>
      </template>
    </view>
  </view>
</template>

<script setup>
  import { privacyStore } from '__biz/privacy'

  const props = defineProps({ modelValue: Boolean })
  const emits = defineEmits(['update:modelValue'])

  let agrees = [
    {
      url: 'https://static.tospurfang.com/asset/大宗云用户服务及隐私协议.html',
      title: '隐私条款'
    }
  ]

  function onAgress() {
    emits('update:modelValue', !props.modelValue)
  }

  function onRead(item) {
    if (item.url) {
      uni.navigateTo({
        url: '/pages_com/web/index?url=' + item.url + '&title=' + item.title
      })
    } else {
      privacyStore().open()
    }
  }
</script>

<style></style>
